package rlex.classes;
import java.util.regex.Pattern;


public class Validator {
	
	public boolean isLetter(String letter) {
		return Pattern.matches("[a-zA-Z]", letter);
	}

	public boolean isNumber(String letter) {
		return Pattern.matches("[0-9]", letter);
	}

	public boolean isSpecialCharacter(String letter) {
		return Pattern.matches("(,)|(;)|(\\.)|(:)|(:)|(:=)|(=)|" +
				"(<)|(>)|(<=)|(>=)|(<>)|(\\+)|(-)|(or)|(\\*)|" +
				"(/)|(and)|(\\()|(\\)|(_))", letter);
	}
	
	public boolean isKeyword(String input) {
		return Pattern.matches("(program)|(var)|(integer)" +
				"|(real)|(boolean)|(procedure)|(begin)|(end)|" +
				"(if)|(then)|(else)|(while)|(do)", input);
	}
	
	public boolean isType(String input) {
		return Pattern.matches("(integer)|(real)|(boolean)", input);
	}
	
	public boolean isIdentifier(String input) {
		return Pattern.matches("[a-z][a-z_A-Z0-9_]*", input);
	}
	
	public boolean isBoolean(String input) {
		return Pattern.matches("(true)|(false)", input);
	}

	public boolean isInteger(String input) {
		return Pattern.matches("[0-9]+", input);
	}

	public boolean isReal(String input) {
		return Pattern.matches("[0-9]+.[0-9]*", input);
	}
	
	public boolean isDelimiter(String input) {
		return Pattern.matches("[\\.\\,;:\\(\\)]", input);
	}
	
	public boolean isAllocation(String input) {
		return Pattern.matches("(:=)", input);
	}
	
	public boolean isRelationalOperator(String input) {
		return Pattern.matches("(=)|(<>)|(<=)|(>=)|(<)|(>)", input);
	}
	
	public boolean isAddOperator(String input) {
		return Pattern.matches("(\\+)|(-)|(or)", input);
	}
	
	public boolean isMultiplicativeOperator(String input) {
		return Pattern.matches("(\\*)|(/)|(and)", input);
	}
	
	public boolean isOpenComment(String input) {
		return Pattern.matches("\\{", input);
	}
	
	public boolean isCloseComment(String input) {
		return Pattern.matches("\\}", input);
	}
		
	public boolean isIgnoreCharacter(String input) {
		return Pattern.matches("(\r\n)|([\t\n\f\r])", input);
	}
}
